﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Cosmetic.Logic;

public partial class Management_ManagementMasterPage : System.Web.UI.MasterPage
{
	private	RoleManager m_RoleManager	= new RoleManager();

    protected void Page_Load(object sender, EventArgs e)
    {
        HtmlLink theCssLink = new HtmlLink();
        theCssLink.Href = "~/css/Management.css";
        theCssLink.Attributes.Add("rel", "stylesheet");
        theCssLink.Attributes.Add("type", "text/css");
        this.Page.Header.Controls.Add(theCssLink);


        //if (null != (this.Page as PageBase).SignInUser)
        //{
        //    Cosmetic.DataEntity.User theUser = (this.Page as PageBase).SignInUser;
        //    if (this.m_RoleManager.CheckUserRole(theUser, RoleManager.ERole.Admin))
        //    {
        //        this.mnuManager.Visible = true;
        //        this.mnuManager.Enabled = true;
        //        this.mnuBlog.Visible = false;
        //        this.mnuBlog.Enabled = false;
        //        this.mnuProduct.Visible = false;
        //        this.mnuProduct.Enabled = false;
        //    }
        //    else if (this.m_RoleManager.CheckUserRole(theUser, RoleManager.ERole.Blog))
        //    {
        //        this.mnuManager.Visible = false;
        //        this.mnuManager.Enabled = false;
        //        this.mnuBlog.Visible = true;
        //        this.mnuBlog.Enabled = true;
        //        this.mnuProduct.Visible = false;
        //        this.mnuProduct.Enabled = false;
        //    }
        //    else if (this.m_RoleManager.CheckUserRole(theUser, RoleManager.ERole.Product))
        //    {
        //        this.mnuManager.Visible = false;
        //        this.mnuManager.Enabled = false;
        //        this.mnuBlog.Visible = false;
        //        this.mnuBlog.Enabled = false;
        //        this.mnuProduct.Visible = true;
        //        this.mnuProduct.Enabled = true;
        //    }
        //    this.ltlSignInAdmin.Text = theUser.NickName;
        //    this.btnSignOut.Visible = true;
        //}
        //else
        //{
        //    this.btnSignOut.Visible = false;
        //    this.mnuManager.Enabled = false;
        //    if (!this.Request.Url.AbsolutePath.ToLower().Contains("indexs.aspx"))
        //    {
        //        this.Response.Redirect(String.Format("~/Management/indexs.aspx", this.Request.Url.PathAndQuery));
        //    }
        //}
    }

	protected void btnSignOut_Click(object sender, EventArgs e)
	{
		(this.Page as PageBase2).SignOut();
		this.Response.Redirect("~/Management/");
	}
}
